package com.pan.utils;


import java.io.*;

public class ErrorLog {

    private static File file;


    static {
        String path = ".\\error\\myError.txt";
        file = new File(path);
        if (!file.exists()){
            try {
                file.createNewFile();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void print(String title,String content){
        String input = title+"\n"+content+"\n==================================\n";
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file,true);
            fileOutputStream.write(input.getBytes());
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        print("title","error test");
    }

}
